#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#include <cassert>
#include <cstdio>
using namespace std;
int global = 0;
void *TimeRoutine(void *args)
{
    char *str = (char *)args;
    while (1)
    {
        cout << "我是一个" << str << "，我正在运行, golbal: "<< global++ <<"&global" << &global << endl;
        sleep(1);
    }
}
int main()
{
    pthread_t tid;
    int n = pthread_create(&tid, nullptr, TimeRoutine, (void *)"子线程");
    assert(0 == n);
    (void)n;
    while (1)
    {
        char buffer[64];
        snprintf(buffer, sizeof buffer, "0x%x", tid);
        cout << "我是主要线程，我正在运行我创建出来的tid:" << buffer << "global: " << global << "&global" << &global << endl;
        sleep(1);
    }
    return 0;
}